package lhc.alg.top100;

/**
 * description: https://leetcode.cn/problems/palindrome-number/
 *  回文数 O(logn) O(1)
 * author: hongchen.liao
 * date:  2022/8/26
 */
public class _9_Palindrome_Number {

    class Solution {
        public boolean isPalindrome(int x) {
            if(x < 0 || (x % 10 == 0 && x > 0)){
                return false;
            }
            int reverseNum = 0;
            while(x > reverseNum){
                reverseNum = reverseNum * 10 + x % 10;
                x /= 10;
            }
            return x == reverseNum || x == reverseNum / 10;
        }
    }


}
